package uts.sdk.modules.oneoilNewland;

import android.content.Context;
import android.os.Bundle;
import android.os.RemoteException;
import com.newland.aidl.voice.AidlVoiceBroadcast;
import com.newland.aidl.voice.VoiceCode;
import uts.sdk.modules.oneoilNewland.R;
import uts.sdk.modules.oneoilNewland.NewlandService;
import uts.sdk.modules.oneoilNewland.ICallback;
import uts.sdk.modules.oneoilNewland.Response;
import com.newland.aidl.beeper.AidlBeeper;

public class VoiceBroadcastAction {
	private AidlVoiceBroadcast voiceBroadcast;
	private AidlBeeper ibeeper;


	
    private VoiceBroadcastAction() {
		voiceBroadcast = NewlandService.getVoiceBroadcast();
		ibeeper = NewlandService.getBeeper();
	}
    
    // 静态内部类不会在外部类加载时立即加载
    private static class VoiceBroadcastActionHolder {
        private static final VoiceBroadcastAction INSTANCE = new VoiceBroadcastAction();
    }
    
    // 第一次调用时才会加载SingletonHolder类
    public static VoiceBroadcastAction getInstance() {
        return VoiceBroadcastActionHolder.INSTANCE;
    }
	
	public boolean startVoice(String text) throws Exception {
		Bundle b = new Bundle();
		b.putString(VoiceCode.VoiceParams.CONTEXT, text);
		//        b.putString(VoiceCode.VoiceParams.LANGUAGE,"CN");
		//        b.putString(VoiceCode.VoiceParams.CONTEXT,"pay for 1 yuan, please.");
		//        b.putString(VoiceCode.VoiceParams.LANGUAGE,"EN");
		return voiceBroadcast.startVoice(b);
	}
	
	public boolean stopVoice() throws Exception {
		return voiceBroadcast.stopVoice();
	}
	 public void startBeep() throws Exception {
	        ibeeper.startBeep(1000);
	    }
		
	   public void stopBeep() throws Exception {
	
	        ibeeper.stopBeep();
	    }
}